package com.example.demo.mapper;

import com.example.demo.entity.ShippingAddress;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
* @author 15085202591
* @description 针对表【shipping_address】的数据库操作Mapper
* @createDate 2024-05-29 15:32:26
* @Entity com.example.demo.entity.ShippingAddress
*/
@Mapper
public interface ShippingAddressMapper extends BaseMapper<ShippingAddress> {

    @Update("update shipping_address set selected = IF(id=#{id},1,0) WHERE uid = #{uid};")
    void updateSelectedById(@Param("id")Long id, @Param("uid")Long uid);

    @Select("select id from shipping_address where selected = 1 and uid = #{uid}")
    Long getIDBySelected(@Param("uid")Long uid);
}




